All, Some and Isempty

Given a predicate p, we can find out if all the elements of a list satisfy p with All~p. Similarly we can find if something in the list satisfies p with Some~p. For example,

#math147#
All~(Lessthan~1)~[1, 2, 3] = : #tex2html_wrap_indisplay2564#Foldr#tex2html_wrap_indisplay2565#@<<#tex2html_wrap_indisplay2566#870>>#tex2html_wrap_indisplay2567##tex2html_wrap_indisplay2568#! :}#tex2html_wrap_indisplay2569#1 ;SPMlt; < <329>>#tex2html_wrap_indisplay2570#[1, 2, 3]TrueFalse  
Some~(Lessthan~1)~[1, 2, 3] = : #tex2html_wrap_indisplay2574##tex2html_wrap_indisplay2575#Foldr#tex2html_wrap_indisplay2576#@@<#tex2html_wrap_indisplay2577#<728>><#tex2html_wrap_indisplay2578#<726>>#tex2html_wrap_indisplay2579#! :}#tex2html_wrap_indisplay2580#1 ;SPMlt; < <333>>#tex2html_wrap_indisplay2581#[1, 2, 3]TrueFalse  

These can be defined
#math148#
All~p = Foldr~(Compose~And~p)~True  
Some~p = Foldr~(Compose~Or~p)~False  

For example, Isempty can be defined
#math149#
Isempty = All~(First~False)  

This is probably not the most efficient check in the world, but we hardly ever need it --- Foldl or Foldr will normally do the job.